﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
using System.Threading;

namespace PacMan
{
    
    enum Bonuses 
    { 
        Cherry,
        Pineapple,
        Apple,
        Banana,
        Strawberry
    }
    
    class Bonus:GameObject
    {
        private Bonuses _currentBonus;
        private int _points;

        public Bonus()
        {
            Width = 30;
            Height = 30;
            X = -100;
            Y = -100;
        }

        
        public int Points 
        {
            get 
            {
                return _points;
            }
            set 
            {
                _points = value;
            }
        }
        
        
        public Bonuses CurrentBonus 
        {
            get 
            {
                return _currentBonus;
            }
            set 
            {
                _currentBonus = value;
            }
        }
        
        private Point WhereBonusAppears(RectangleF[] maze) 
        {
            Random rand = new Random();
            
            RectangleF bonus = new RectangleF(rand.Next(Environment.MinX,Environment.MaxX),rand.Next(Environment.MinY,Environment.MaxY),50,50);

            while (Environment.IsAbleToCreateObject(maze, bonus, maze.Length, 1) != true) 
            {
                bonus = new RectangleF(rand.Next(Environment.MinX, Environment.MaxX), rand.Next(Environment.MinY, Environment.MaxY), 50, 50);
            }
            return new Point((int)bonus.X, (int)bonus.Y);
        }
 
        public void BonusChoosing(RectangleF[] maze) 
        {
            var point = WhereBonusAppears(maze);
            this.X = point.X;
            this.Y = point.Y;
            Random rand = new Random();
            int bonus = rand.Next(1, 6);
            switch (bonus) 
            {
                case 1: 
                    {
                        _currentBonus = Bonuses.Cherry;
                        _points = 100;
                        break;
                    }
                case 2:
                    {
                        _currentBonus = Bonuses.Pineapple;
                        _points = 200;
                        break;
                    }
                case 3:
                    {
                        _currentBonus = Bonuses.Apple;
                        _points = 300;
                        break;
                    }
                case 4:
                    {
                        _currentBonus = Bonuses.Banana;
                        _points = 400;
                        break;
                    }
                case 5:
                    {
                        _currentBonus = Bonuses.Strawberry;
                        _points = 500;
                        break;
                    }
            }
        }

        
    }
    
    
    
}
